package com.mzxy.c1625163415.base;

import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import butterknife.ButterKnife;
import butterknife.Unbinder;

public abstract class BaseActivity extends AppCompatActivity {
    private Unbinder unbinder;

    @LayoutRes
    protected abstract int getContentId();

    public abstract void initData(Bundle savedInstanceState);

    /**
     * 初始化零件
     */
    public abstract void initView();

    /**
     * 初始化点击事件
     */
    public abstract void initListen();

    /**
     * 逻辑使用区
     */
    public abstract void processLogic();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        try {
            setContentView(getContentId());
            Log.e("baseAct--->", this.getClass().getSimpleName());
            unbinder = ButterKnife.bind(this);
            initData(savedInstanceState);
            initView();
            initListen();
            processLogic();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unbinder.unbind();
    }
}
